package bairui.international.console.web.controller.advance.category.properties.item;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;

import bairui.international.model.domain.jpa.TB_ProductPropertyItem;
import bairui.international.model.domain.jpa.id.ID_ProductCategoryProperty;
import bairui.international.service.Service_ProductPropertyItem;

/**
 *
 * 属性项添加
 *
 * @generated
 * 
 * @see STest_C_Advance_Category_PropertiesItemAdd_Page 测试
 *
 */
@Controller
public class C_Advance_Category_PropertiesItemAdd_Page
 extends SC_Advance_Category_PropertiesItemAdd_Page 
{
	
	@Autowired private Service_ProductPropertyItem service_ProductPropertyItem;
	
	/**
	 * 分页列表
	 */
	@Action(Page.class)
	@GetMapping(value=Page.RequestMappingValue, consumes=MediaType.APPLICATION_JSON_VALUE)
	public @FomatOutput @ResponseBody Object page(
		HttpServletRequest request, 
		@PathVariable(name=Page.PathVariableName.CategoryId) long categoryId, 
		@PathVariable(name=Page.PathVariableName.PropertyId) ID_ProductCategoryProperty propertyId
	) throws Exception {
		org.springframework.data.domain.Page<TB_ProductPropertyItem> page = service_ProductPropertyItem.page(
				it->Page.Filter.query(it, request)
					.and(it.productProperty.eq(propertyId.getProductProperty()))
					.and(it.productCategoryPropertyItems.any().productCategoryProperty.id.eq(propertyId).not()), 
				Page.Output.page(request), 
				it->Page.Output.sort(it, request)
			);
		//
		return Page.Output.output(
				page
			);
	}
	

}
